#include <stdio.h>
#include <string.h>


char ins1[3], ins2[3];
int sx, sy, ex, ey;

struct Node
{
    int x, y, step;     
};
Node queue[70];
int movex[]={1,1, -1,-1,2,-2,2,-2};
int movey[]={2,-2, 2,-2,1,1,-1,-1};
int flag[9][9];
/*
struct Student
{
       int number;
       char name[10];
};
*/
void bfs()
{
     int head, tail, i;
     int answer;
     Node  now, next;
     queue[0].x = sx;
     queue[0].y = sy;
     queue[0].step = 0;
     head = 0;
     tail = 1;
     while ( tail > head ) 
     {
           now = queue[head];
           if (now.x == ex && now.y == ey) {
                answer = now.step;
                break;    
           }
           head ++;
           for (i = 0; i < 8; ++ i)
           {
               next.x = now.x + movex[i];
               next.y = now.y + movey[i];
               next.step = now.step + 1;
               if (next.x >= 1 && next.x <= 8 
                && next.y >= 1 && next.y <= 8 
                && flag[next.x][next.y] == 0) 
               {
                   flag[next.x][next.y] = 1;
                   queue[tail] = next;
                   tail ++;
               }
           }
     } // end of search
     
     // output
     printf("To get from %s to %s takes %d knight moves.\n", ins1, ins2, answer);
}

int main()
{
/*    Student s1, s2;
    scanf("%s %d", &s1.name, &s1.number);
    printf("name=%s, number=%d\n", s1.name, s1.number);
    s2 = s1;
*/    
    while (1) {
          if (scanf("%s%s", ins1, ins2) == EOF) break;// EOF = end of file
          // convert
          sx = ins1[0] - 'a' + 1;
          sy = ins1[1] - '0';
          ex = ins2[0] - 'a' + 1;
          ey = ins2[1] - '0';
          // branch first search
          // depth frrst search
          memset(flag, 0, sizeof(flag));
          
          bfs();
    }    
    
    
    return 0;
}
